package com.TTBook.impl.category.daoImpl;

import com.TTBook.core.category.dao.BookCategoryDAO;
import com.TTBook.core.category.model.BookCategory;
import com.TTBook.core.category.model.BookCategoryCriteria;
import java.util.List;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

public class BookCategoryDAOImpl extends SqlMapClientDaoSupport implements BookCategoryDAO {

    public BookCategoryDAOImpl() {
        super();
    }

    public int countByCriteria(BookCategoryCriteria criteria) {
        Integer count = (Integer)  getSqlMapClientTemplate().queryForObject("ts_book_category.countByCriteria", criteria);
        return count.intValue();
    }

    public int deleteByCriteria(BookCategoryCriteria criteria) {
        int rows = getSqlMapClientTemplate().delete("ts_book_category.deleteByCriteria", criteria);
        return rows;
    }

    public void insert(BookCategory record) {
        getSqlMapClientTemplate().insert("ts_book_category.insert", record);
    }

    public void insertSelective(BookCategory record) {
        getSqlMapClientTemplate().insert("ts_book_category.insertSelective", record);
    }

    public List selectByCriteria(BookCategoryCriteria criteria) {
        List list = getSqlMapClientTemplate().queryForList("ts_book_category.selectByCriteria", criteria);
        return list;
    }

    public int updateByCriteriaSelective(BookCategory record, BookCategoryCriteria criteria) {
        UpdateByCriteriaParms parms = new UpdateByCriteriaParms(record, criteria);
        int rows = getSqlMapClientTemplate().update("ts_book_category.updateByCriteriaSelective", parms);
        return rows;
    }

    public int updateByCriteria(BookCategory record, BookCategoryCriteria example) {
        UpdateByCriteriaParms parms = new UpdateByCriteriaParms(record, example);
        int rows = getSqlMapClientTemplate().update("ts_book_category.updateByCriteria", parms);
        return rows;
    }

    private static class UpdateByCriteriaParms extends BookCategoryCriteria {
        private Object record;

        public UpdateByCriteriaParms(Object record, BookCategoryCriteria criteria) {
            super(criteria);
            this.record = record;
        }

        public Object getRecord() {
            return record;
        }
    }
}